home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 16 / balcol.zip / BALCOL.TXT next >
Text File  |  1989-02-07  |  23KB  |  382 lines

  1.                                                                 7 February 1989
  2.  
  3.                              BALCOL (Version 1.01)
  4.               A WordPerfect 5.0 Macro to Produce Two-Column Text
  5.                              with Balanced Columns
  6.  
  7.                   Rufus S. Hendon (CompuServe ID 73250,2674)
  8.  
  9.  
  10.                                  Introduction
  11.  
  12.      WordPerfect 5.0 has good facilities for formatting text in two columns.
  13. (It is also possible to use three or more columns, but I will talk only about
  14. the case of two columns.)  One feature that is lacking, however, is a simple
  15. way to equalize the lengths of the columns on the last or only page containing
  16. a section of two-column text to allow room for subsequent single-column text on
  17. the same page.  If, on the last page used, there is not enough text to fill a
  18. column, WordPerfect puts all the text in the left column and permits single-
  19. column text to follow on the same page, but there is an unsightly blank space
  20. in the right column.  If there is more text than will fit in the left column,
  21. WordPerfect fills that column to the end of the page and then puts the
  22. remainder of the text in the right column, leaving the rest of that column
  23. blank; single-column text is forced to the next page.
  24.  
  25.      The preferable treatment, of course, is for the two-column text to be
  26. formatted, on the last or only page of such text, with the two columns
  27. balanced, i.e. with approximately the same number of lines in both columns, in
  28. order to avoid the presence of blank areas on the page and to allow single-
  29. column text to follow on the same page.  It is possible to achieve this effect
  30. manually (I will describe the procedure later), but the process is tedious.
  31.  
  32.      A friend recently wanted to prepare camera-ready copy of her dissertation
  33. for publication, with the body of the text formatted in dual columns.  I was
  34. helping her with the details, and decided to see if I could devise a macro that
  35. would, to some extent, at least, automate the process of producing two-column
  36. text with balanced columns.  The macro that resulted is described in this memo.
  37. The macro, called BALCOL, is stored in two files named BALCOL.WPM and
  38. BALCOL1.WPM.  You invoke BALCOL from WordPerfect; BALCOL in turn calls upon
  39. BALCOL1 to perform certain tasks.  Both files must be present in the directory
  40. where WordPerfect looks for macros.
  41.  
  42.      This is an early version of BALCOL (version 1.01).  It does its job
  43. properly on the documents I have used to test it, and hence I would expect it
  44. to work for you also, as long as the documents you apply it to are formatted in
  45. the way to be described.  In developing BALCOL, however, I discovered that
  46. there are many things that can go wrong with a macro this complicated.  It is
  47. therefore quite possible that on certain occasions BALCOL will give unexpected
  48. results or will trash a part of your document.  For this reason you should take
  49. seriously the suggestions for backup procedures given below.  You use BALCOL at
  50. your own risk.
  51.  
  52.      One reason why I am distributing this early version of the macro is the
  53. hope that some of the macro wizards who participate in the WPSG Forum will be
  54. interested in taking a look at it.  Any suggestions for correcting errors they
  55. spot, making the behavior of the macro more stable, and improving its operation
  56. will be very welcome.  I am therefore making available a more technical
  57. discussion of the macro in a separate memo (BCTECH.TXT).
  58.  
  59.  
  60.                     General description of what BALCOL does
  61.  
  62.      BALCOL is intended for use with documents that consist of sections of text
  63. to be formatted in double columns separated by sections of text to be formatted
  64. in a single column.  The full-width sections interrupting the two-column
  65. sections might, for example, be headings that you want to extend across both
  66. columns, tables too wide to fit in one of the two columns, and the like.  This
  67. memo is an example of such a document, if we assume that the centered headings
  68. such as "General description of what BALCOL does" are to be printed extending
  69. across both columns while the paragraphs of text are to be printed in dual
  70. columns.
  71.  
  72.      BALCOL allows you to bracket a section of text which it then formats in
  73. double columns, beginning at the current position on the page and using as many
  74. pages as are required to hold the text.  On the last or only page occupied by
  75. the two-column text, the text is divided as evenly as possible between the two
  76. columns.  If the two columns don't take up the entire page, the following piece
  77. of full-width text will begin on the same page, below the two columns.  In most
  78. cases, BALCOL preserves the number of blank lines that originally separated the
  79. double-column section from the full-width section.  There are occasional
  80. lapses, however, that require manual correction, usually the deletion of an
  81. extra blank line.  Other sporadic formatting failures may likewise have to be
  82. repaired by hand.
  83.  
  84.      On each of the pages occupied by two-column text, BALCOL checks to see if
  85. there are blank lines at the tops of the columns.  If this is the case, it
  86. gives you the opportunity to delete them.
  87.  
  88.  
  89.                       The expected format of the document
  90.  
  91.      BALCOL was designed to operate on documents formatted in this manner:
  92.  
  93.      (1) The document includes, prior to the first section to be formatted in
  94. double columns, a column definition specifying the type as newspaper, the
  95. number of columns as 2, and whatever column separation or margins you want to
  96. use.  This is essential:  BALCOL won't work if there is no column definition in
  97. effect.  If you use tabs to indent paragraphs that are to be printed in two
  98. columns, you would also want to set tab stops on the basis of the column
  99. definition so that a tab will give the same amount of indentation regardless of
  100. whether the paragraph ends up in the left column or the right column.  Suppose,
  101. for example, that your document has 1" left and right margins and you have set
  102. the distance between columns to 0.25" in the column definition.  WordPerfect
  103. will tell you, when you define the columns, that the left column begins 1" and
  104. the right column 4.37" from the left edge of the paper.  To indent paragraphs
  105. 0.25" (which will look better than the usual 0.5"), you would have to have tab
  106. stops set at 1.25" and 4.62".
  107.  
  108.      (2) Every section to be printed in two columns is separated from the
  109. following full-width section by at least one blank line.  Applying BALCOL to a
  110. document that fails to satisfy this requirement will introduce errors in the
  111. paragraphing of the subsequent text.
  112.  
  113.      (3) Blank lines are produced simply by pressing Enter (Return), and hence
  114. consist solely of a Hard Return, without preceding spaces or tabs.  Blank lines
  115. that violate this requirement may cause minor errors in the operation of
  116. BALCOL, since they will not be recognized as blank lines.
  117.  
  118.      BALCOL will not work on text containing embedded graphics.
  119.  
  120.  
  121.                                How to use BALCOL
  122.  
  123.      In a long document containing many separate sections to be given two-
  124. column format, you will be using BALCOL frequently.  You might therefore find
  125. it convenient to change the name of the file BALCOL.WPM, at least temporarily,
  126. to ALTB.WPM, so that you can use the Alt-B key to invoke the macro.  If you do
  127. this, don't alter the name of BALCOL1.WPM.
  128.  
  129.      Two-column formatting must be applied to units that are isolated from
  130. other parts of the document by obligatory page breaks.  For short documents,
  131. the entire document may constitute such a unit, in which case the formatting
  132. must be applied to the document as a whole.  In other cases, the document may
  133. be subdivided into parts, such as chapters, that are independent of each other
  134. in the sense that each part is forced to begin on a new page.  Each of these
  135. parts can then be converted to dual-column format separately.  For the sake of
  136. convenience, I will henceforth use the term "document" to refer to the contents
  137. of the file to which dual-column formatting is to be applied; this may be an
  138. entire document (in the more general sense) or an independent unit of a
  139. document of the sort just described.
  140.  
  141.      The conversion of a document to two-column format should be deferred until
  142. you are absolutely certain that it is in final form as far as content and all
  143. formatting other than the conversion to two columns are concerned.  Until you
  144. reach this point, put the column definition at the beginning of the file but
  145. keep all text in single-column form.  The reason for this is that once the
  146. switch has been made to two columns the document has assumed a frozen state in
  147. which it is no longer easy to make modifications (such as the addition or
  148. deletion of text or a change in the typeface or point size to be used for
  149. printing) that would alter the quantity of text or the way text wraps from one
  150. line to the next.
  151.  
  152.      When you are ready to do the two-column formatting, make a copy of the
  153. file containing the document.  Let's call the file containing the finished
  154. document in its one-column form "file 1".  The copy is "file 2"; this is the
  155. file to which BALCOL will be applied.  If file 2 gets messed up in the process,
  156. the original text of the document will still be available in file 1.  Also, if,
  157. despite your belief that the text of the document is in its final form, it
  158. later appears that changes have to be made, you will still have a single-column
  159. version of the text in file 1 on which to make the alterations; you can then
  160. make a new file 2 from the modified version of file 1 and redo the two-column
  161. formatting.
  162.  
  163.      I also strongly recommend that, as you work through file 2 with BALCOL,
  164. you save the current version of file 2 in another file, "file 3", after each
  165. successful conversion of a section of text to double-column format.  Having
  166. this continually updated backup of your work will save you a lot of effort if,
  167. at some point, the conversion of the next section to be processed messes up the
  168. text, either because BALCOL misbehaves or because of some error on your part.
  169. If you have faithfully kept the backup in file 3 current after the conversion
  170. of each section, you can restore the status of file 2 just before the faulty
  171. conversion by retrieving file 3.  You can then retry BALCOL on the section
  172. where things went bad previously or, if you feel that BALCOL was at fault, you
  173. can format and balance this particular section by hand, using the procedure to
  174. be described later.
  175.  
  176.      If you get through successfully to the end of the file, file 3 and file 2
  177. (after you save it) will be identical, and one of the two can be discarded.
  178.  
  179.      Two-column formatting must be done on sections in order, working from the
  180. beginning of the text to the end.  If this memo were the document, for
  181. instance, the first section to be processed would consist of the paragraphs
  182. coming between the heading "Introduction" and the heading "General description
  183. of what BALCOL does", if we assume that headings are to be printed as full-
  184. width items stretching across both columns.  Reformatting would then be applied
  185. to the next section, which consists of the paragraphs between the heading
  186. "General description of what BALCOL does" and the heading "The expected format
  187. of the document".  Conversion to dual-column format would continue in this way,
  188. section by section, until the end of the document was reached.
  189.  
  190.      Here are the steps to follow (it is assumed that BALCOL.WPM has been
  191. renamed to ALTB.WPM, so that BALCOL can be invoked by pressing Alt-B):
  192.  
  193.      (1) Copy the file to be converted to two-column format, file 1, into a new
  194. file, file 2.
  195.  
  196.      (2) Start WordPerfect and retrieve file 2.
  197.  
  198.      (3) Move the cursor to the first line of the next section of text to be
  199. converted to two-column format.  (The first time, this will be the first such
  200. section in the text.  Thereafter it will be the next section in order.)  It
  201. doesn't matter where the cursor is in the line.  (If this memo were the
  202. document, you would, for the first section, put the cursor somewhere in the
  203. first line of the first paragraph, which begins "WordPerfect 5.0 has good
  204. facilities".)
  205.  
  206.      (4) Press Alt-B.  A small rectangle will appear before the first word in
  207. the line and this message will be shown at the bottom of the screen:
  208.  
  209.         Move cursor to last line of two-column text, then press Enter.
  210.  
  211.      (5) Move the cursor to the last line of the section of text to be
  212. reformatted.  (This is the last line of text in the last paragraph in the
  213. section, not the blank line that follows the last paragraph.)  It doesn't
  214. matter just where the cursor is in the last line.  When you have positioned the
  215. cursor, note (for use in step 7) the number of blank lines between this line
  216. and the following full-width item.  Then press Enter (Return).  (For the first
  217. section of this memo, you would put the cursor somewhere in the line
  218. "discussion of the macro in a separate memo (BCTECH.TXT)." and press Enter.)  A
  219. small rectangle will materialize at the end of the line.
  220.  
  221.      (6) Wait!  BALCOL starts chugging away, and various intermediate forms of
  222. the text of the section will appear on the screen.  If BALCOL discovers that
  223. there are blank lines at the tops of columns, it will, for each case, beep and
  224. ask if you want to delete the line.
  225.  
  226.      (7) When BALCOL has finished processing the section, the end of the
  227. section, with balanced columns, will be displayed, and the status line at the
  228. bottom of the screen will revert to its usual state, showing the name of the
  229. file you are working on.  Examine the reformatted section carefully, to see if
  230. any manual corrections to what BALCOL has done are needed.  If the section
  231. extends over several pages, page back to the beginning of the section and then
  232. scan it page by page.  Particularly if the text is justified, you will find it
  233. helpful to use the View feature on the Print (Shift-F7) key, since the View
  234. display will reveal any deviations from correct justification.
  235.  
  236.      (8) If everything looks okay, press Save (F10) to save the current state
  237. of the document in the running backup file, file 3.  (The first time you do
  238. this, WordPerfect will ask you for the name of the file, suggesting the name of
  239. the file you are working on, file 2.  Change this to a different name, for file
  240. 3.  Thereafter WordPerfect will suggest the name of file 3; press Enter to
  241. accept this name and then type "y" to authorize WordPerfect to replace the
  242. previous contents of file 3.)  If there is another section to be processed, go
  243. back to step 3.  Otherwise exit from WordPerfect, saving file 2 (make sure to
  244. specify the name of file 2 rather than the name of file 3 when WordPerfect asks
  245. for the name of the file to be saved).  At this point file 2 and file 3 are
  246. identical so one of them can be deleted.
  247.  
  248.      (9) If, however, you notice formatting mistakes, they must be fixed before
  249. you can proceed to subsequent sections.  Make the necessary corrections and
  250. then go to step 8.
  251.  
  252.      Errors requiring hand correction are normally confined to the last or only
  253. page occupied by the section.  The commonest mistake is the introduction of an
  254. extra blank line, which must be removed by hand.  BALCOL usually keeps the
  255. number of blank lines separating the end of the two-column section from the
  256. following full-width item the same.  Occasionally, however, it introduces an
  257. extra line, so that, for instance, three blank lines appear where originally
  258. there were only two.  If this is the case, turn Reveal Codes (Alt-F3 or F11)
  259. on, move the cursor to a [HRt] code in the vicinity of the [Col Off] code
  260. between the end of the two-column section and the full-width item, and press
  261. Delete.  Then turn Reveal Codes off.  (It is essential to have Reveal Codes on
  262. when you do this, so that you can avoid deleting the wrong code.  When the
  263. cursor is resting on a blank line, it may be on some code other than [HRt].  If
  264. you don't have Reveal Codes on, you may see the cursor on a blank line and
  265. press Delete, thinking that this will remove the blank line; but if in fact the
  266. cursor is not on a [HRt] code, the results of pressing Delete may be quite
  267. unexpected.)
  268.  
  269.      The error just described is easy to fix.  There may be occasions, however,
  270. when BALCOL has fouled things up so badly that the only course is to start over
  271. again on this particular section and perform the conversion to dual-column
  272. format with balanced columns by hand.  When this is the case, use Exit (F7),
  273. "n", "n" to get rid of the current, now defective version of file 2 on which
  274. you've been working and then use Retrieve (Shift-F10) to load the backup from
  275. file 3. This restores the document used by WordPerfect to the state it had
  276. before you tried to reformat the section that caused BALCOL to misbehave.
  277. Convert this section using the manual procedure described below.  Then go to
  278. step 8.
  279.  
  280.  
  281.            The manual procedure for converting to two-column format
  282.                              with balanced columns
  283.  
  284.      If you have to process a section of text by hand, this is what to do:
  285.  
  286.      (1) Move the cursor to the first line of the section and use Home, Home,
  287. Left Arrow to put it at the beginning of the line.  Then press Math/Columns
  288. (Alt-F7), Column On/Off (3) to turn column formatting on.  This inserts a [Col
  289. On] code, and puts the entire document from this point on into dual columns.
  290.  
  291.      (2) Move the cursor to the last line of the section.  If the last line is
  292. in the right column, use Goto (Ctrl-Home), Right Arrow to switch from the left
  293. column to the right column.  Press End to put the cursor at the end of the
  294. line.  Then press Math/Columns (Alt-F7), Column On/Off (3) to turn column
  295. formatting off.  This inserts a [Col Off] code and returns everything in the
  296. document subsequent to this point to single-column format.
  297.  
  298.      (3) If the section spans more than one page, go back to the page on which
  299. it starts.  Examine the non-final pages in sequence, checking the two columns,
  300. first the left and then the right, for unwanted blank lines at the top of the
  301. column.  If you find such a line, delete it.
  302.  
  303.      (4) Go to the last or only page occupied by the section.  If there is a
  304. superfluous blank line at the top of the left column, delete it.  Don't do
  305. anything to the right column at this point.
  306.  
  307.      (5) Count the number of lines of two-column text on this final page.  Let
  308. n = the number of lines divided by 2, rounded up to the next higher integer if
  309. the result is not an integer.  For example, if there are 46 lines, n = 23; if
  310. thee are 47 lines, n = 24.
  311.  
  312.      (6) Go to the top of the left column on the final page and move the cursor
  313. down to the nth line of the column.  Move the cursor down to the beginning of
  314. the next line and press Ctrl-Enter to insert Hard Page at that point (between
  315. line n and line n+1).  You will see all the lines after line n move from the
  316. left column to the top of the right column, making the lengths of the two
  317. columns approximately equal.
  318.  
  319.      (7) If justification is in effect and line n is not the last line of a
  320. paragraph (and hence must be justified when printed), turn Reveal Codes (Alt-F3
  321. or F11) on.  You will see that line n ends with a either a [SRt] (Soft Return)
  322. code or a [HPg] (Hard Page) code; in the former case, there will be a [HPg]
  323. code by itself on the next line.  Position the cursor so that the code at the
  324. end of line n, [SRt] or [HPg], is highlighted.  If the highlighted code is not
  325. preceded by a space, press Spacebar to insert one.  Then type one or more Hard
  326. Spaces (Home, Spacebar).  Each Hard Space will be shown as [ ] in the Reveal
  327. Codes display.  As long as the series of Hard Spaces is shown ahead of the
  328. highlighted code, type another.  Eventually you will see the string of Hard
  329. Spaces drop down to a new line in the Reveal Codes display, followed by [HPg];
  330. the preceding line (line n) will have [SRt] at the end.
  331.  
  332.      Let's look at a specific example.  Suppose that after step 6 the last line
  333. of the left column on the last page occupied by the section of dual-column text
  334. is this:
  335.  
  336.         improving its operation.  I am
  337.  
  338. This is not the end of the paragraph, which continues at the top of the right
  339. column.  Reveal Codes shows this:
  340.  
  341.         improving its operation.  I am[SRt]
  342.         [HPg]
  343.  
  344. This makes the line look, to WordPerfect, like the end of a paragraph, since
  345. the [HPg], which like [HRt] causes a break in justification, takes precedence
  346. over the [SRt].  Consequently WordPerfect won't justify the line when it is
  347. printed.  Move the cursor to highlight the [SRt].  Since this isn't preceded by
  348. a space, press Spacebar to insert one.  Then type Hard Spaces (Home, Spacebar)
  349. until a new line is created (don't be bothered if at some point the [SRt]
  350. disappears and is replaced by the [HPg], which moves up to this line).  Let's
  351. say that it takes nine Hard Spaces to accomplish this.  The Reveal Codes
  352. display now looks like this:
  353.  
  354.         improving its operation.  I am[SRt]
  355.         [ ][ ][ ][ ][ ][ ][ ][ ][ ][HPg]
  356.  
  357. The line beginning with "improving" no longer looks like a paragraph-final line
  358. to WordPerfect, and so it will be printed with justification.  There is now an
  359. extra line in the left column, but since the word it contains is composed
  360. entirely of Hard Spaces it will look like a blank line when printed.
  361.  
  362.      (8) Look at the top of the right column on the last or only page occupied
  363. by this two-column section.  If there is an unwanted blank line at the top of
  364. the column, delete it.
  365.  
  366.      (9) Go to the bottom of the right column and turn Reveal Codes on.  If
  367. there is a [HPg] code immediately preceding or following the [Col Off] code,
  368. delete it.
  369.  
  370.      (10) Examine the transition from the dual-column text to the following
  371. full-width item (heading or the like).  If the number of blank lines preceding
  372. the full-width item is greater than it originally was, turn the Reveal Codes
  373. display on (if it isn't already on) and delete as many [HRt] codes preceding
  374. the full-width item as necessary to reduce the number of blank lines to the
  375. original value.  Delete only [HRt] codes found on a line in which the [HRt] is
  376. all by itself or is accompanied only by codes that don't generate text.  (Extra
  377. blank lines appear for two reasons.  The first is that WordPerfect tends to
  378. insert a [HRt] along with [Col Off].  The second reason is that the strategem
  379. to force justification of the last line of the left column described in step 7
  380. introduces an additional, apparently blank line.  Deleting [Hrt] codes removes
  381. blank lines to compensate for these introduced lines.)
  382.